package com.webserver.core;

import com.webserver.http.HttpResponse;
import com.webserver.http.HttpResquest;

import java.io.File;

public class DispatcherServlet {
    public void service(HttpResquest httpResquest, HttpResponse httpResponse){
        String path = httpResquest.getUrl();
        File file = new File("./webapps"+path);
        if(file.exists()&&file.isFile()){
            httpResponse.setEntity(file);
        }else{
            httpResponse.setStatusCode("404");
            httpResponse.setStatusReson("Not Found");
            file = new File("./webapps/root/404.html");
            httpResponse.setEntity(file);
        }
    }
}
